import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {ValidateProvider} from "../../providers/validate/validate";
import {HttpServicesProvider} from "../../providers/http-services/http-services";
import {UtilsProvider} from "../../providers/utils/utils";

@IonicPage({
    segment:'information/publish/navlist',
    defaultHistory:['MemberPage']
})
@Component({
    selector: 'page-information-style',
    templateUrl: 'information-style.html',
})
export class InformationStylePage {
    navlist:any;
    constructor(
        public navCtrl: NavController,
        public navParams: NavParams,
        public validate: ValidateProvider,
        public httpService: HttpServicesProvider,
        public util: UtilsProvider
    ) {
        if (!this.validate.checkLogin()) {
            this.navCtrl.push('LoginPage');
        }
    }
    ionViewCanEnter(){
        return this.validate.checkLogin();
    }

    ionViewWillEnter(){
        this.getNavList();
    }

    /**
     * 获取发布信息分类
     * */
    getNavList(){
        let apiUrl = "/task_info/information_nav";
        this.httpService.requestPostData(apiUrl,{},response=>{
            if(response['error'] == 200){
                this.navlist = response['data'];
            }else{
                this.util.presentAlert('数据请求失败，请稍后再试！');
                this.navCtrl.pop();
            }

        })
    }

    /**
     * 跳转至发布消息页面
     * */
    goToPublish(type_id){
        this.navCtrl.push('InformationAddPage',{
            type_id: type_id,
            kind: 'information'
        });
    }



}
